<template>
  <div class="home">
    <el-container>
      <el-header>
        <h2>UNI-ADMIN</h2>
        <div>
          <el-menu
            :default-active="activeIndex"
            class="el-menu-demo"
            mode="horizontal"
            background-color="#2e2e2e"
            text-color="#fff"
            @select="handleSelect"
            active-text-color="#ffd04b"
          >
            <el-menu-item index="1">首页</el-menu-item>
            <el-menu-item index="2">商品</el-menu-item>
            <el-menu-item index="3">订单</el-menu-item>
            <el-menu-item index="4">会员</el-menu-item>
            <el-menu-item index="5">设置</el-menu-item>
          </el-menu>
        </div>
      </el-header>
      <router-view></router-view>
    </el-container>
  </div>
</template>

<script>
export default {
  data() {
    return {
      activeIndex: '1',
    };
  },
  methods: {
    handleSelect(key, keyPath) {
        console.log(key, keyPath);
        this.activeIndex=key;
        var path="";
        switch(key){
          case "1":
          path="/";
          break;
          case "2":
          path="/store";
          break;
          case "3":
          path="/order";
          break;
          case "4":
          path="/member";
          break;
          case "5":
          path="/setting";
          break;
          default:
            break;
        }
        this.$router.push(path)
      }
  },
};
</script>
<style scoped>
.el-header {
  background-color: #2e2e2e;
  color: white;
  text-align: center;
  line-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-around;
}
.el-header ul li {
  float: left;
  margin-left: 40px;
  color: white;
  line-height: 60px;
  list-style: none;
}
.el-aside {
  background-color: white;
  color: #000;
  text-align: center;
  line-height: 400px;
  height: 500px;
  border: 1px solid #000;
}
.el-menu{
  background-color: #2e2e2e;
}
.el-main {
  background-color: rgba(128, 128, 128, 0.11);
  color: #000;
  text-align: center;
  line-height: 400px;
  border: 1px solid #000;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
.el-menu-item.active{
  color: white;
}
</style>
